<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>注册账号</title>
 <link rel="stylesheet" href="static/css/common_form.css">
</head>
<body ng-app="registerApp">
 <header>
 <div class="header-line"></div>
 </header>
 <div class="content">
 <img class="content-logo" src="static/image/form_logo.jpg" alt="logo">
 <h1 class="content-title">创建账户</h1>
 <div class="content-form">
  <form method="post" action="" name="registerForm" ng-controller="register">
  <div id="change_margin_1">
   <input class="user"  spellcheck="false"  type="text" name="username" placeholder="请输入用户名" ng-model="formData.username" ng-minlength="6" ng-maxlenth="16" required/>
  </div>
  <!-- input的value为空时弹出提醒 -->
  <p id="remind_1">
   <span style="color:red" ng-show="registerForm.username.$invalid">
   <span ng-show="registerForm.username.$error.minlength">
         *用户名不得少于6位
   </span>
   <span ng-show="registerForm.username.$error.maxlenth">
        *用户名不得超过16位
   </span>
</span>
  </p>
  <div id="change_margin_2">
   <input class="password" type="password" name="password" placeholder="请输入密码"   ng-model="formData.password" ng-minlength="6" ng-maxlength="16" required/>
  </div>
  <!-- input的value为空时弹出提醒 -->
  <p id="remind_2">
  <span style="color:red" ng-show="registerForm.password.$invalid">
      <span ng-show="registerForm.password.$error.minlength">
	 *密码不得少于6位
	  </span>
      <span style="color:red" ng-show="registerForm.password.$error.maxlength">
      密码不得超过16位
     </span>
	</span>
  </p>
  <div id="change_margin_3">
   <input class="content-form-signup" type="button" value="创建账户" ng-controller="register" ng-click="asave()"  ng-disabled="registerForm.username.$invalid || registerForm.password.$invalid"/>
  </div>
  </form>
 </div>
 <div class="content-login-description">已经拥有账户？</div>
 <div><a class="content-login-link" href="/login">登录</a></div>
 </div>
</body>
<script src="static/js/jquery-2.1.1.min.js"></script>
<script src="static/js/aj.js"></script>
<script src="static/layer-2.4/layer.js"></script>
<script type="text/javascript">
var app = angular.module('registerApp',[]);
    app.config(['$interpolateProvider', function($interpolateProvider) {
    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');
}]);
app.controller('register',['$scope',function($scope){

}]);
  var register = app.controller('register',['$scope','$http',function($scope,$http){
     $scope.asave= function(){
         $http({
             method: 'POST',
             url: '/register',
             data: $.param($scope.formData), // pass in data as strings
             headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}  
         }).success(function (data) {
           if(data.errorNumber==0x05){
            layer.alert('用户名已存在', {icon: 5});
            //layer.alert("用户名不存在");
          }else{  
             location.href = "/login";
           }
          });
 
     };
 }]);

</script>
</html>
</html>